cmake_minimum_required(VERSION 2.8)

if (CMAKE_HOST_UNIX)
   macro(LIST_APPEND_PATH VARIABLE)
      foreach(_extra ${ARGN})
         string(REPLACE ":" ";" _extra_path ${_extra})
         list(APPEND ${VARIABLE} ${_extra_path})
         unset(_extra_path)
      endforeach()
   endmacro()

   macro(LIST_PREPEND_PATH VARIABLE)
      foreach(_extra ${ARGN})
         string(REPLACE ":" ";" _extra_path ${_extra})
         list(INSERT ${VARIABLE} 0 ${_extra_path})
         unset(_extra_path)
      endforeach()
   endmacro()

   # help CMake find C/C++ includes and libraries
   # (note: the environment variables specified here are used by gcc)
   LIST_PREPEND_PATH(CMAKE_INCLUDE_PATH $ENV{CPATH})
   LIST_PREPEND_PATH(CMAKE_LIBRARY_PATH $ENV{LIBRARY_PATH})
endif()
